home *** CD-ROM | disk | FTP | other *** search
- //
- // Stationary Target Tracking AI file
- //
- // Behaviors:
- //
- // If idle, look periodically for enemy units to target.
- // Track enemy units and attack while in weapon range.
- // Continue tracking while in LOS.
- // When target leaves LOS, return to idle.
- //
- // Notes:
- //
- // This behavior is mainly used for stationary units like guard towers.
- //
- // Common modifications:
- //
- // Known Problems:
- //
- // Units will track an enemy unit outside weapon range even if there
- // are other enemy units *within* weapon range. MUST FIX THIS!
- //
- // Usage:
- //
- // To tell a unit to attack another unit, give it an attack goal (EEUGAttackUnit or EEUGAttackGround)
- // and set it's action to keeuaTrackEnemyUnit.
- //
-
- // any tasty enemies around?
- Idle
- {
- EnemyUnitSpotted true(TrackEnemyUnit)
- }
-
- // follow enemy unit (perhaps with a turret?) until it's in weapon range or moves away
- TrackEnemyUnit
- {
- anyof(EnemyUnitDestroyed,CeaseFire,UnitNotOnMap,EnemyUnitNoLongerVisible,EnemyWithinMinimumRange) true(Idle)
- allof(Reloaded,UnitInWeaponRange) true(AttackEnemyUnit)
- EnemyUnitLeftLOS true(Idle)
-
- // the next trigger allows the tower to respond to attacks, but only if it's attacking on it's own
- // note that the "EnemyIsBuilding" trigger is left out here - don't let 'em fool us by keeping a unit just out of range
- allof(AmIUnderAttack,GoalIsNotPlayerInitiated,UnitNotInWeaponRange) true(UnderAttack)
- }
-
- // attack enemy unit unti it dies or moves away
- AttackEnemyUnit
- {
- anyof(EnemyUnitDestroyed,CeaseFire,UnitNotOnMap,EnemyUnitNoLongerVisible,EnemyWithinMinimumRange) true(Idle)
- UnitInWeaponRange false(TrackEnemyUnit)
- EnemyUnitLeftLOS true(Idle)
-
- // the next trigger allows the tower to respond to attacks, but only if it's attacking a building on it's own
- allof(AmIUnderAttack,GoalIsNotPlayerInitiated,EnemyIsBuilding) true(UnderAttack)
-
- AlwaysTrue true(TrackEnemyUnit)
- }
-
- RetaliateAgainstAttacker
- {
- allof(GoalIsUnit,UnitInWeaponRange) true(TrackEnemyUnit) false(Idle)
- }
-
- UnderAttack
- {
- allof(UnitInWeaponRange,CanDamageAttacker) true(RetaliateAgainstAttacker) false(Idle)
- }
-
- // attack the target until it is destroyed or moves
- InitialAttackState
- {
- AlwaysTrue true(TrackEnemyUnit)
- }
-